package com.example.howard.mytcpclient;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

public class ShowLogViewAdapter extends ArrayAdapter<String> {

    protected LayoutInflater mInflater;

    private static final int mResource = R.layout.tv_item;


    List<String> ContentList = null ;


    public ShowLogViewAdapter(Context context, List<String> contentList) {
        super(context, 0,contentList);

        mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        ContentList = contentList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewCacheOfOrder holder ;

        if(convertView == null){

            convertView = mInflater.inflate(mResource, null);
            holder = new ViewCacheOfOrder();
            holder.tv_content = (TextView) convertView.findViewById(R.id.tv_item);
            convertView.setTag(holder);

        }else{

            holder = (ViewCacheOfOrder)convertView.getTag();

        }

        holder.tv_content.setText(ContentList.get(position));

        return convertView;
    }


    static class ViewCacheOfOrder{

        TextView tv_content;

    }
}
